﻿@model List<EAM.Model.AssetCategory>
@{
    var conList = (List<EAM.Model.AssetManagerConfig>)ViewBag.conList;
}
<table class="tb">
@{
    int i = 0;
}
@foreach (var m in Model)
{
    var conModel = conList.FirstOrDefault(a => a.AssetManConfigTypeID == m.CategoryID);
    if (i % 2 == 0)
    {
        <text><tr></text>
    }

    <td>
        @m.CategoryName
    </td>
    <td>
        @if (m.CategoryChooseType == 1)
        {
            <input type="text" id="@(m.CategoryLabel + m.CategoryParentID)" name="@(m.CategoryLabel + m.CategoryParentID)" value="@(conModel != null ? conModel.AssetManConfigValue : "")" />
        }
        else if (m.CategoryChooseType == 2)
        {
            <select id="@(m.CategoryLabel + m.CategoryParentID)" name="@(m.CategoryLabel + m.CategoryParentID)">
                @{
                    var arr = m.CategoryChooseValue.Split(',');
                }
                @foreach (var item in arr)
                {
                    <option value="@item" @if (conModel != null && conModel.AssetManConfigValue == item) { <text>selected="selected"</text> }>@item</option>
                }
            </select>
        }
    </td>

    i++;
    if ((i > 0 && (i % 2 == 0)) || i == Model.Count)
    {
        @:</tr>
    }
}
</table>